package cn.well.cloud.core.auth.userdetail;

import cn.well.cloud.base.auth.model.LoginUser;
import cn.well.cloud.base.auth.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * UserDetailsService只负责从特定的地方（通常是数据库）加载用户信息
 * 自定义UserDetailsService的实现，灵活可控
 * 用户详情信息获取
 * 2019年12月23日
 * @author wison
 *
 */
@Service("jwtUserDetailsService")
public class JwtUserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private AuthService authService;

    @Override
    public LoginUser loadUserByUsername(String username) throws UsernameNotFoundException {
        return authService.user(username);
    }
}
